﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aima.NET.Test.Core.Agent.Impl
{
    using Aima.Core.Agent;
    using Aima.Core.Agent.Impl;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class PerceptSequenceTest 
    {

        [TestMethod]
        public void TestToString() {
            IList<IPercept> ps = new List<IPercept>();
            ps.Add(new DynamicPercept("key1", "value1"));

            Assert.AreEqual("[IPercept[key1==value1]]", ps.Aggregate(new StringBuilder("["), (sb,p) => sb.Append(p + ", "), sb => sb.ToString().Substring(0, sb.ToString().Length - 2) + "]"));

            ps.Add(new DynamicPercept("key1", "value1", "key2", "value2"));

            Assert.AreEqual(
                    "[IPercept[key1==value1], IPercept[key1==value1, key2==value2]]",
                    ps.Aggregate(new StringBuilder("["), (sb, p) => sb.Append(p + ", "), sb => sb.ToString().Substring(0, sb.ToString().Length - 2) + "]"));
        }

        //TODO: figure out if this is really needed. In that case equality comparer will need to be overriden for List
        [TestMethod]
        [Ignore]
        public void TestEquals() {
            IList<IPercept> ps1 = new List<IPercept>();
            IList<IPercept> ps2 = new List<IPercept>();

            Assert.AreEqual(ps1, ps2);

            ps1.Add(new DynamicPercept("key1", "value1"));

            Assert.AreNotSame(ps1, ps2);

            ps2.Add(new DynamicPercept("key1", "value1"));

            Assert.AreEqual(ps1, ps2);
        }
    }

}
